﻿@using S4sme.Web.Infrastructure.Helpers;
@using S4sme.Core.Configuration;
@model S4sme.Domain.Post

@{
    Layout = "../Shared/_BlogLayout.cshtml";
}

@section Stylesheets {
    <link href="@Url.Content("~/Content/css/prettify/desert.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/jquery.lightbox-0.5.css")" rel="stylesheet" type="text/css" />
}

@section Javascripts {
<script type="text/javascript" src="@Url.Content("~/Content/js/prettify/prettify.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jquery.lightbox-0.5.js")"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('a.lightbox').lightBox({ fixedNavigation: true });
    });
</script>
}

@section Prettify {onload="prettyPrint()"}

<div id="maincntblog">
    <div class="postcontent">
      <h3>
        @Model.Title</h3>
      <p>
        @Html.Raw(Model.Content)</p>
      <div class="postinfo">Categories: @string.Join(", ", Model.Categories.Select(c => c.Name)) <br />Tags: @string.Join(", ", Model.Tags.Select(c => c.Name))</div>
      <div class="postdate">
        @Model.CreatedDate.ToLongDateString()</div>
    </div>
    <h3 class="commenttitle">
      Showing @Model.Comments.Where(x => x.IsApproved).Count() comments</h3>
    @foreach (var comment in Model.Comments.Where(x => x.IsApproved).OrderBy(x => x.CreatedDate))
    {
      <div class="commentcontent @Html.Raw(Settings.BlogAuthorEmails.Contains(comment.Email) ? "commentalt" : string.Empty)">
       <table class="commentauthor">
        <tbody>
          <tr>
            <td>
              @Html.Raw(Html.Gravatar(comment.Email,90))
            </td>
            <td>
                @if (!string.IsNullOrWhiteSpace(comment.Website)) 
                {
                    <a href="@comment.Website">@comment.Author</a>
                }else { 
                    @comment.Author
                }
                 - <span class="commentauthordate">@comment.CreatedDate.ToLongDateString()</span>
            </td>
          </tr>
        </tbody>
      </table>
      <div class="commentbody">
        @Html.Raw(comment.Content.Replace("\r","<br/>"))</div>
    </div>
    }
    <h3 class="commenttitle">
      Add new comment</h3>
    <div id="commentformarea" class="formbase">
      @if(TempData["Errors"] != null)
      {
          var list = TempData["Errors"] as List<string>;
     <div class="validation-summary-errors"><span>Please correct the following</span>
     <ul>
         @foreach (var error in list) 
         { 
            <li>@error</li>
         }
      </ul></div>
      }
      @*Html.ValidationSummary("Fix the following errors")*@
      @using (Html.BeginForm("Edit", "Comment", FormMethod.Post, new { id = "commentform" })) {
      @Html.Hidden("Comment.PostFk", Model.Id)
      <table id="addcomment">
        <tbody>
          <tr>
            <td colspan="2">
                @Html.Label("Comment.Content","Your comments *")
              <br />
              @Html.TextArea("Comment.Content", null, new {rows="5", cols="40"})
              @*Html.ValidationMessage("Comment.Content", "*")*@
            </td>
          </tr>
          <tr>
            <td>
                @Html.Label("Comment.Author", "Name *")
              <br />
              @Html.TextBox("Comment.Author", null, new {@class="comment"})
              @*Html.ValidationMessage("Comment.Author", "*")*@
            </td>
            <td>
            @Html.Label("Comment.Email", "Email *")
              <br />
                @Html.TextBox("Comment.Email", null, new { @class = "comment" })
              @*Html.ValidationMessage("Comment.Email", "*")*@
            </td>
          </tr>
          <tr>
            <td>
            @Html.Label("Comment.Website", "Website (optional):")
              <br />
              @Html.TextBox("Comment.Website", null, new {@class="comment"})
              @*Html.ValidationMessage("Comment.Website", "*")*@
            </td>
            <td>
              <br />
              @Html.CheckBox("Comment.Subscribe")
              Subscribe to all comments by email
            </td>
          </tr>
          <tr><td><input type="submit" id="commentsubmit" class="btnsubmit" value="Submit Comment &gt;&gt;"/></td></tr>
        </tbody>
      </table>
      }
    </div>
  </div>

@*
<asp:Content ID="rightbar" ContentPlaceHolderID="RightBarContent" runat="server">
  <%Html.RenderPartial("RightBar", Model.RightBarData); %>
</asp:Content>
*@
@*
<asp:Content ID="scriptholderid" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
<script type="text/javascript" src="<%= Url.Content("~/content/js/shCore.js") %>"></script>
<script type="text/javascript" src="<%= Url.Content("~/content/js//shBrushCSharp.js") %>"></script>
<script type="text/javascript" src="<%= Url.Content("~/content/js/shBrushCss.js") %>"></script>
<script type="text/javascript" src="<%= Url.Content("~/content/js/shBrushXml.js") %>"></script>
<script type="text/javascript" src="<%= Url.Content("~/content/js/shBrushJScript.js") %>"></script>
  <script type="text/javascript">
      SyntaxHighlighter.config.clipboardSwf = '<%= Url.Content("~/content/js/clipboard.swf") %>';
      SyntaxHighlighter.all();
	</script>
</asp:Content>
*@